<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Coverage for c:\program files\python26\lib\string</title>
<link rel='stylesheet' href='style.css' type='text/css'>
<script type='text/javascript' src='jquery-1.3.2.min.js'></script>
<script type='text/javascript'>
function toggle_lines(btn, cls) {
    var btn = $(btn);
    var hide = "hide_"+cls;
    if (btn.hasClass(hide)) {
        $("#source ."+cls).removeClass(hide);
        btn.removeClass(hide);
    }
    else {
        $("#source ."+cls).addClass(hide);
        btn.addClass(hide);
    }
}
</script>
</head>
<body>
<div id='header'>
    <div class='content'>
        <h1>Coverage for <b>c:\program files\python26\lib\string</b> :
            <span class='pc_cov'>1%</span>
        </h1>
        <h2 class='stats'>
            223 statements
            <span class='run hide_run' onclick='toggle_lines(this, "run")'>2 run</span>
            <span class='exc' onclick='toggle_lines(this, "exc")'>0 excluded</span>
            <span class='mis' onclick='toggle_lines(this, "mis")'>221 missing</span>
            
                <span class='par run hide_run' onclick='toggle_lines(this, "par")'>0 partial</span>
            
        </h2>
    </div>
</div>

<div id='source'>
<table cellspacing='0' cellpadding='0'>
<tr>
<td class='linenos' valign='top'>
<p class='pln'>1</p>
<p class='pln'>2</p>
<p class='pln'>3</p>
<p class='pln'>4</p>
<p class='pln'>5</p>
<p class='pln'>6</p>
<p class='pln'>7</p>
<p class='pln'>8</p>
<p class='pln'>9</p>
<p class='pln'>10</p>
<p class='pln'>11</p>
<p class='pln'>12</p>
<p class='pln'>13</p>
<p class='pln'>14</p>
<p class='pln'>15</p>
<p class='pln'>16</p>
<p class='pln'>17</p>
<p class='pln'>18</p>
<p class='pln'>19</p>
<p class='pln'>20</p>
<p class='pln'>21</p>
<p class='pln'>22</p>
<p class='stm mis'>23</p>
<p class='stm mis'>24</p>
<p class='stm mis'>25</p>
<p class='stm mis'>26</p>
<p class='stm mis'>27</p>
<p class='stm mis'>28</p>
<p class='stm mis'>29</p>
<p class='stm mis'>30</p>
<p class='stm mis'>31</p>
<p class='stm mis'>32</p>
<p class='stm mis'>33</p>
<p class='stm mis'>34</p>
<p class='pln'>35</p>
<p class='pln'>36</p>
<p class='pln'>37</p>
<p class='stm mis'>38</p>
<p class='stm mis'>39</p>
<p class='stm mis'>40</p>
<p class='pln'>41</p>
<p class='pln'>42</p>
<p class='pln'>43</p>
<p class='pln'>44</p>
<p class='stm mis'>45</p>
<p class='pln'>46</p>
<p class='pln'>47</p>
<p class='pln'>48</p>
<p class='pln'>49</p>
<p class='pln'>50</p>
<p class='pln'>51</p>
<p class='pln'>52</p>
<p class='pln'>53</p>
<p class='stm mis'>54</p>
<p class='pln'>55</p>
<p class='pln'>56</p>
<p class='pln'>57</p>
<p class='stm mis'>58</p>
<p class='stm mis'>59</p>
<p class='pln'>60</p>
<p class='pln'>61</p>
<p class='pln'>62</p>
<p class='pln'>63</p>
<p class='pln'>64</p>
<p class='pln'>65</p>
<p class='pln'>66</p>
<p class='stm mis'>67</p>
<p class='stm mis'>68</p>
<p class='pln'>69</p>
<p class='stm mis'>70</p>
<p class='stm mis'>71</p>
<p class='stm mis'>72</p>
<p class='stm mis'>73</p>
<p class='stm mis'>74</p>
<p class='stm mis'>75</p>
<p class='stm mis'>76</p>
<p class='pln'>77</p>
<p class='pln'>78</p>
<p class='pln'>79</p>
<p class='pln'>80</p>
<p class='stm mis'>81</p>
<p class='pln'>82</p>
<p class='stm mis'>83</p>
<p class='pln'>84</p>
<p class='pln'>85</p>
<p class='pln'>86</p>
<p class='pln'>87</p>
<p class='pln'>88</p>
<p class='stm mis'>89</p>
<p class='stm mis'>90</p>
<p class='stm mis'>91</p>
<p class='pln'>92</p>
<p class='stm mis'>93</p>
<p class='stm mis'>94</p>
<p class='stm mis'>95</p>
<p class='stm mis'>96</p>
<p class='stm mis'>97</p>
<p class='pln'>98</p>
<p class='pln'>99</p>
<p class='stm mis'>100</p>
<p class='stm mis'>101</p>
<p class='pln'>102</p>
<p class='pln'>103</p>
<p class='pln'>104</p>
<p class='pln'>105</p>
<p class='pln'>106</p>
<p class='pln'>107</p>
<p class='pln'>108</p>
<p class='pln'>109</p>
<p class='stm mis'>110</p>
<p class='stm mis'>111</p>
<p class='stm mis'>112</p>
<p class='stm mis'>113</p>
<p class='pln'>114</p>
<p class='stm mis'>115</p>
<p class='pln'>116</p>
<p class='pln'>117</p>
<p class='pln'>118</p>
<p class='stm mis'>119</p>
<p class='pln'>120</p>
<p class='pln'>121</p>
<p class='stm mis'>122</p>
<p class='pln'>123</p>
<p class='stm mis'>124</p>
<p class='pln'>125</p>
<p class='stm mis'>126</p>
<p class='stm mis'>127</p>
<p class='pln'>128</p>
<p class='stm mis'>129</p>
<p class='stm mis'>130</p>
<p class='pln'>131</p>
<p class='pln'>132</p>
<p class='pln'>133</p>
<p class='stm mis'>134</p>
<p class='stm mis'>135</p>
<p class='stm mis'>136</p>
<p class='stm mis'>137</p>
<p class='stm mis'>138</p>
<p class='stm mis'>139</p>
<p class='pln'>140</p>
<p class='stm mis'>141</p>
<p class='stm mis'>142</p>
<p class='stm mis'>143</p>
<p class='pln'>144</p>
<p class='pln'>145</p>
<p class='stm mis'>146</p>
<p class='stm mis'>147</p>
<p class='stm mis'>148</p>
<p class='stm mis'>149</p>
<p class='stm mis'>150</p>
<p class='stm mis'>151</p>
<p class='stm mis'>152</p>
<p class='pln'>153</p>
<p class='stm mis'>154</p>
<p class='pln'>155</p>
<p class='stm mis'>156</p>
<p class='pln'>157</p>
<p class='stm mis'>158</p>
<p class='stm mis'>159</p>
<p class='stm mis'>160</p>
<p class='pln'>161</p>
<p class='pln'>162</p>
<p class='stm mis'>163</p>
<p class='stm mis'>164</p>
<p class='stm mis'>165</p>
<p class='stm mis'>166</p>
<p class='stm mis'>167</p>
<p class='stm mis'>168</p>
<p class='pln'>169</p>
<p class='stm mis'>170</p>
<p class='pln'>171</p>
<p class='stm mis'>172</p>
<p class='stm mis'>173</p>
<p class='stm mis'>174</p>
<p class='stm mis'>175</p>
<p class='stm mis'>176</p>
<p class='stm mis'>177</p>
<p class='stm mis'>178</p>
<p class='pln'>179</p>
<p class='stm mis'>180</p>
<p class='pln'>181</p>
<p class='stm mis'>182</p>
<p class='stm mis'>183</p>
<p class='stm mis'>184</p>
<p class='stm mis'>185</p>
<p class='pln'>186</p>
<p class='pln'>187</p>
<p class='stm mis'>188</p>
<p class='stm mis'>189</p>
<p class='stm mis'>190</p>
<p class='stm mis'>191</p>
<p class='stm mis'>192</p>
<p class='stm mis'>193</p>
<p class='stm mis'>194</p>
<p class='stm mis'>195</p>
<p class='stm mis'>196</p>
<p class='stm mis'>197</p>
<p class='stm mis'>198</p>
<p class='stm mis'>199</p>
<p class='stm mis'>200</p>
<p class='stm mis'>201</p>
<p class='pln'>202</p>
<p class='stm mis'>203</p>
<p class='pln'>204</p>
<p class='pln'>205</p>
<p class='pln'>206</p>
<p class='pln'>207</p>
<p class='pln'>208</p>
<p class='pln'>209</p>
<p class='pln'>210</p>
<p class='pln'>211</p>
<p class='stm mis'>212</p>
<p class='stm mis'>213</p>
<p class='stm mis'>214</p>
<p class='stm mis'>215</p>
<p class='pln'>216</p>
<p class='pln'>217</p>
<p class='stm mis'>218</p>
<p class='pln'>219</p>
<p class='pln'>220</p>
<p class='pln'>221</p>
<p class='pln'>222</p>
<p class='pln'>223</p>
<p class='stm run hide_run'>224</p>
<p class='pln'>225</p>
<p class='pln'>226</p>
<p class='stm mis'>227</p>
<p class='pln'>228</p>
<p class='pln'>229</p>
<p class='pln'>230</p>
<p class='pln'>231</p>
<p class='pln'>232</p>
<p class='stm mis'>233</p>
<p class='pln'>234</p>
<p class='pln'>235</p>
<p class='stm mis'>236</p>
<p class='pln'>237</p>
<p class='pln'>238</p>
<p class='pln'>239</p>
<p class='pln'>240</p>
<p class='pln'>241</p>
<p class='pln'>242</p>
<p class='stm mis'>243</p>
<p class='pln'>244</p>
<p class='pln'>245</p>
<p class='stm mis'>246</p>
<p class='pln'>247</p>
<p class='pln'>248</p>
<p class='pln'>249</p>
<p class='pln'>250</p>
<p class='pln'>251</p>
<p class='pln'>252</p>
<p class='pln'>253</p>
<p class='pln'>254</p>
<p class='stm mis'>255</p>
<p class='pln'>256</p>
<p class='pln'>257</p>
<p class='stm mis'>258</p>
<p class='pln'>259</p>
<p class='pln'>260</p>
<p class='pln'>261</p>
<p class='pln'>262</p>
<p class='pln'>263</p>
<p class='pln'>264</p>
<p class='stm mis'>265</p>
<p class='pln'>266</p>
<p class='pln'>267</p>
<p class='stm mis'>268</p>
<p class='pln'>269</p>
<p class='pln'>270</p>
<p class='pln'>271</p>
<p class='pln'>272</p>
<p class='pln'>273</p>
<p class='pln'>274</p>
<p class='stm mis'>275</p>
<p class='pln'>276</p>
<p class='pln'>277</p>
<p class='pln'>278</p>
<p class='stm mis'>279</p>
<p class='pln'>280</p>
<p class='pln'>281</p>
<p class='pln'>282</p>
<p class='pln'>283</p>
<p class='pln'>284</p>
<p class='pln'>285</p>
<p class='pln'>286</p>
<p class='pln'>287</p>
<p class='pln'>288</p>
<p class='pln'>289</p>
<p class='stm mis'>290</p>
<p class='stm mis'>291</p>
<p class='pln'>292</p>
<p class='pln'>293</p>
<p class='stm mis'>294</p>
<p class='pln'>295</p>
<p class='pln'>296</p>
<p class='pln'>297</p>
<p class='pln'>298</p>
<p class='pln'>299</p>
<p class='pln'>300</p>
<p class='pln'>301</p>
<p class='pln'>302</p>
<p class='stm mis'>303</p>
<p class='pln'>304</p>
<p class='pln'>305</p>
<p class='stm mis'>306</p>
<p class='pln'>307</p>
<p class='pln'>308</p>
<p class='pln'>309</p>
<p class='pln'>310</p>
<p class='pln'>311</p>
<p class='pln'>312</p>
<p class='pln'>313</p>
<p class='pln'>314</p>
<p class='pln'>315</p>
<p class='stm mis'>316</p>
<p class='stm mis'>317</p>
<p class='pln'>318</p>
<p class='pln'>319</p>
<p class='stm mis'>320</p>
<p class='pln'>321</p>
<p class='pln'>322</p>
<p class='pln'>323</p>
<p class='pln'>324</p>
<p class='pln'>325</p>
<p class='stm mis'>326</p>
<p class='pln'>327</p>
<p class='pln'>328</p>
<p class='stm mis'>329</p>
<p class='pln'>330</p>
<p class='pln'>331</p>
<p class='pln'>332</p>
<p class='pln'>333</p>
<p class='pln'>334</p>
<p class='stm mis'>335</p>
<p class='pln'>336</p>
<p class='pln'>337</p>
<p class='stm mis'>338</p>
<p class='pln'>339</p>
<p class='pln'>340</p>
<p class='pln'>341</p>
<p class='pln'>342</p>
<p class='pln'>343</p>
<p class='pln'>344</p>
<p class='pln'>345</p>
<p class='stm mis'>346</p>
<p class='pln'>347</p>
<p class='pln'>348</p>
<p class='stm mis'>349</p>
<p class='pln'>350</p>
<p class='pln'>351</p>
<p class='pln'>352</p>
<p class='pln'>353</p>
<p class='pln'>354</p>
<p class='pln'>355</p>
<p class='pln'>356</p>
<p class='pln'>357</p>
<p class='pln'>358</p>
<p class='stm mis'>359</p>
<p class='pln'>360</p>
<p class='pln'>361</p>
<p class='stm mis'>362</p>
<p class='pln'>363</p>
<p class='pln'>364</p>
<p class='pln'>365</p>
<p class='pln'>366</p>
<p class='pln'>367</p>
<p class='pln'>368</p>
<p class='pln'>369</p>
<p class='pln'>370</p>
<p class='pln'>371</p>
<p class='stm run hide_run'>372</p>
<p class='pln'>373</p>
<p class='pln'>374</p>
<p class='stm mis'>375</p>
<p class='stm mis'>376</p>
<p class='stm mis'>377</p>
<p class='pln'>378</p>
<p class='pln'>379</p>
<p class='stm mis'>380</p>
<p class='pln'>381</p>
<p class='pln'>382</p>
<p class='pln'>383</p>
<p class='pln'>384</p>
<p class='pln'>385</p>
<p class='stm mis'>386</p>
<p class='pln'>387</p>
<p class='pln'>388</p>
<p class='pln'>389</p>
<p class='stm mis'>390</p>
<p class='pln'>391</p>
<p class='pln'>392</p>
<p class='pln'>393</p>
<p class='pln'>394</p>
<p class='pln'>395</p>
<p class='pln'>396</p>
<p class='pln'>397</p>
<p class='pln'>398</p>
<p class='pln'>399</p>
<p class='pln'>400</p>
<p class='stm mis'>401</p>
<p class='pln'>402</p>
<p class='pln'>403</p>
<p class='pln'>404</p>
<p class='stm mis'>405</p>
<p class='pln'>406</p>
<p class='pln'>407</p>
<p class='pln'>408</p>
<p class='pln'>409</p>
<p class='pln'>410</p>
<p class='pln'>411</p>
<p class='pln'>412</p>
<p class='pln'>413</p>
<p class='pln'>414</p>
<p class='pln'>415</p>
<p class='pln'>416</p>
<p class='stm mis'>417</p>
<p class='pln'>418</p>
<p class='pln'>419</p>
<p class='pln'>420</p>
<p class='stm mis'>421</p>
<p class='pln'>422</p>
<p class='pln'>423</p>
<p class='pln'>424</p>
<p class='pln'>425</p>
<p class='pln'>426</p>
<p class='pln'>427</p>
<p class='pln'>428</p>
<p class='stm mis'>429</p>
<p class='pln'>430</p>
<p class='pln'>431</p>
<p class='stm mis'>432</p>
<p class='pln'>433</p>
<p class='pln'>434</p>
<p class='pln'>435</p>
<p class='pln'>436</p>
<p class='pln'>437</p>
<p class='pln'>438</p>
<p class='pln'>439</p>
<p class='stm mis'>440</p>
<p class='pln'>441</p>
<p class='pln'>442</p>
<p class='stm mis'>443</p>
<p class='pln'>444</p>
<p class='pln'>445</p>
<p class='pln'>446</p>
<p class='pln'>447</p>
<p class='pln'>448</p>
<p class='pln'>449</p>
<p class='pln'>450</p>
<p class='stm mis'>451</p>
<p class='pln'>452</p>
<p class='pln'>453</p>
<p class='pln'>454</p>
<p class='pln'>455</p>
<p class='stm mis'>456</p>
<p class='pln'>457</p>
<p class='pln'>458</p>
<p class='pln'>459</p>
<p class='pln'>460</p>
<p class='pln'>461</p>
<p class='pln'>462</p>
<p class='stm mis'>463</p>
<p class='stm mis'>464</p>
<p class='stm mis'>465</p>
<p class='pln'>466</p>
<p class='pln'>467</p>
<p class='pln'>468</p>
<p class='stm mis'>469</p>
<p class='pln'>470</p>
<p class='pln'>471</p>
<p class='pln'>472</p>
<p class='pln'>473</p>
<p class='pln'>474</p>
<p class='pln'>475</p>
<p class='pln'>476</p>
<p class='stm mis'>477</p>
<p class='pln'>478</p>
<p class='pln'>479</p>
<p class='stm mis'>480</p>
<p class='pln'>481</p>
<p class='pln'>482</p>
<p class='pln'>483</p>
<p class='pln'>484</p>
<p class='pln'>485</p>
<p class='pln'>486</p>
<p class='pln'>487</p>
<p class='pln'>488</p>
<p class='pln'>489</p>
<p class='stm mis'>490</p>
<p class='stm mis'>491</p>
<p class='pln'>492</p>
<p class='pln'>493</p>
<p class='pln'>494</p>
<p class='pln'>495</p>
<p class='stm mis'>496</p>
<p class='pln'>497</p>
<p class='pln'>498</p>
<p class='stm mis'>499</p>
<p class='pln'>500</p>
<p class='pln'>501</p>
<p class='pln'>502</p>
<p class='pln'>503</p>
<p class='pln'>504</p>
<p class='pln'>505</p>
<p class='stm mis'>506</p>
<p class='pln'>507</p>
<p class='pln'>508</p>
<p class='stm mis'>509</p>
<p class='pln'>510</p>
<p class='pln'>511</p>
<p class='pln'>512</p>
<p class='pln'>513</p>
<p class='pln'>514</p>
<p class='pln'>515</p>
<p class='pln'>516</p>
<p class='stm mis'>517</p>
<p class='pln'>518</p>
<p class='pln'>519</p>
<p class='pln'>520</p>
<p class='pln'>521</p>
<p class='pln'>522</p>
<p class='pln'>523</p>
<p class='pln'>524</p>
<p class='stm mis'>525</p>
<p class='stm mis'>526</p>
<p class='stm mis'>527</p>
<p class='stm mis'>528</p>
<p class='stm mis'>529</p>
<p class='pln'>530</p>
<p class='pln'>531</p>
<p class='pln'>532</p>
<p class='pln'>533</p>
<p class='pln'>534</p>
<p class='pln'>535</p>
<p class='pln'>536</p>
<p class='pln'>537</p>
<p class='pln'>538</p>
<p class='pln'>539</p>
<p class='pln'>540</p>
<p class='stm mis'>541</p>
<p class='stm mis'>542</p>
<p class='stm mis'>543</p>
<p class='pln'>544</p>
<p class='stm mis'>545</p>
<p class='stm mis'>546</p>
<p class='stm mis'>547</p>
<p class='stm mis'>548</p>
<p class='stm mis'>549</p>
<p class='pln'>550</p>
<p class='stm mis'>551</p>
<p class='stm mis'>552</p>
<p class='stm mis'>553</p>
<p class='stm mis'>554</p>
<p class='stm mis'>555</p>
<p class='pln'>556</p>
<p class='pln'>557</p>
<p class='pln'>558</p>
<p class='stm mis'>559</p>
<p class='stm mis'>560</p>
<p class='pln'>561</p>
<p class='pln'>562</p>
<p class='stm mis'>563</p>
<p class='pln'>564</p>
<p class='pln'>565</p>
<p class='pln'>566</p>
<p class='pln'>567</p>
<p class='pln'>568</p>
<p class='stm mis'>569</p>
<p class='stm mis'>570</p>
<p class='pln'>571</p>
<p class='pln'>572</p>
<p class='stm mis'>573</p>
<p class='pln'>574</p>
<p class='pln'>575</p>
<p class='stm mis'>576</p>
<p class='pln'>577</p>
<p class='pln'>578</p>
<p class='pln'>579</p>
<p class='stm mis'>580</p>
<p class='pln'>581</p>
<p class='stm mis'>582</p>
<p class='pln'>583</p>
<p class='pln'>584</p>
<p class='stm mis'>585</p>
<p class='stm mis'>586</p>
<p class='stm mis'>587</p>
<p class='pln'>588</p>
<p class='stm mis'>589</p>
<p class='pln'>590</p>
<p class='pln'>591</p>
<p class='stm mis'>592</p>
<p class='stm mis'>593</p>
<p class='pln'>594</p>
<p class='pln'>595</p>
<p class='stm mis'>596</p>
<p class='stm mis'>597</p>
<p class='pln'>598</p>
<p class='pln'>599</p>
<p class='stm mis'>600</p>
<p class='pln'>601</p>
<p class='stm mis'>602</p>
<p class='stm mis'>603</p>
<p class='stm mis'>604</p>
<p class='stm mis'>605</p>
<p class='stm mis'>606</p>
<p class='stm mis'>607</p>
<p class='stm mis'>608</p>
<p class='pln'>609</p>
<p class='pln'>610</p>
<p class='pln'>611</p>
<p class='pln'>612</p>
<p class='pln'>613</p>
<p class='pln'>614</p>
<p class='pln'>615</p>
<p class='pln'>616</p>
<p class='pln'>617</p>
<p class='stm mis'>618</p>
<p class='stm mis'>619</p>
<p class='pln'>620</p>
<p class='pln'>621</p>
<p class='pln'>622</p>
<p class='pln'>623</p>
<p class='pln'>624</p>
<p class='pln'>625</p>
<p class='pln'>626</p>
<p class='stm mis'>627</p>
<p class='stm mis'>628</p>
<p class='pln'>629</p>
<p class='stm mis'>630</p>
<p class='pln'>631</p>
<p class='pln'>632</p>
<p class='pln'>633</p>
<p class='stm mis'>634</p>
<p class='stm mis'>635</p>
<p class='stm mis'>636</p>
<p class='pln'>637</p>
<p class='stm mis'>638</p>
<p class='pln'>639</p>
<p class='stm mis'>640</p>
    
</td>
<td class='text' valign='top'>
<p class='pln'><span class='str'>&quot;&quot;&quot;A collection of string operations (most are no longer used).</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>Warning: most of the code you see here isn&#39;t normally used nowadays.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>Beginning with Python 1.6, many of these functions are implemented as</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>methods on the standard string object. They used to be implemented by</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>a built-in module called strop, but strop is now obsolete itself.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>Public module variables:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>whitespace -- a string containing all characters considered whitespace</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>lowercase -- a string containing all characters considered lowercase letters</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>uppercase -- a string containing all characters considered uppercase letters</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>letters -- a string containing all characters considered letters</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>digits -- a string containing all characters considered decimal digits</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>hexdigits -- a string containing all characters considered hexadecimal digits</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>octdigits -- a string containing all characters considered octal digits</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>punctuation -- a string containing all characters considered punctuation</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>printable -- a string containing all characters considered printable</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Some strings for ctype-style character classification</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>whitespace</span> <span class='op'>=</span> <span class='str'>&#39; \t\n\r\v\f&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>lowercase</span> <span class='op'>=</span> <span class='str'>&#39;abcdefghijklmnopqrstuvwxyz&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>uppercase</span> <span class='op'>=</span> <span class='str'>&#39;ABCDEFGHIJKLMNOPQRSTUVWXYZ&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>letters</span> <span class='op'>=</span> <span class='nam'>lowercase</span> <span class='op'>+</span> <span class='nam'>uppercase</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>ascii_lowercase</span> <span class='op'>=</span> <span class='nam'>lowercase</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>ascii_uppercase</span> <span class='op'>=</span> <span class='nam'>uppercase</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>ascii_letters</span> <span class='op'>=</span> <span class='nam'>ascii_lowercase</span> <span class='op'>+</span> <span class='nam'>ascii_uppercase</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>digits</span> <span class='op'>=</span> <span class='str'>&#39;0123456789&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>hexdigits</span> <span class='op'>=</span> <span class='nam'>digits</span> <span class='op'>+</span> <span class='str'>&#39;abcdef&#39;</span> <span class='op'>+</span> <span class='str'>&#39;ABCDEF&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>octdigits</span> <span class='op'>=</span> <span class='str'>&#39;01234567&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>punctuation</span> <span class='op'>=</span> <span class='str'>&quot;&quot;&quot;!&quot;#$%&amp;&#39;()*+,-./:;&lt;=&gt;?@[\]^_`{|}~&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>printable</span> <span class='op'>=</span> <span class='nam'>digits</span> <span class='op'>+</span> <span class='nam'>letters</span> <span class='op'>+</span> <span class='nam'>punctuation</span> <span class='op'>+</span> <span class='nam'>whitespace</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Case conversion helpers</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Use str to convert Unicode literal in case of -U</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>l</span> <span class='op'>=</span> <span class='nam'>map</span><span class='op'>(</span><span class='nam'>chr</span><span class='op'>,</span> <span class='nam'>xrange</span><span class='op'>(</span><span class='num'>256</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>_idmap</span> <span class='op'>=</span> <span class='nam'>str</span><span class='op'>(</span><span class='str'>&#39;&#39;</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>l</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>del</span> <span class='nam'>l</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Functions which aren&#39;t available as string methods.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Capitalize the words in a string, e.g. &quot; aBc&nbsp; dEf &quot; -&gt; &quot;Abc Def&quot;.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>capwords</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>sep</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;capwords(s, [sep]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Split the argument into words using split, capitalize each</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; word using capitalize, and join the capitalized words using</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; join. Note that this replaces runs of whitespace characters by</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; a single space.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='op'>(</span><span class='nam'>sep</span> <span class='key'>or</span> <span class='str'>&#39; &#39;</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='op'>[</span><span class='nam'>x</span><span class='op'>.</span><span class='nam'>capitalize</span><span class='op'>(</span><span class='op'>)</span> <span class='key'>for</span> <span class='nam'>x</span> <span class='key'>in</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='nam'>sep</span><span class='op'>)</span><span class='op'>]</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Construct a translation string</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>_idmapL</span> <span class='op'>=</span> <span class='nam'>None</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>maketrans</span><span class='op'>(</span><span class='nam'>fromstr</span><span class='op'>,</span> <span class='nam'>tostr</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;maketrans(frm, to) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a translation table (a string of 256 bytes long)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; suitable for use in string.translate.&nbsp; The strings frm and to</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; must be of the same length.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>fromstr</span><span class='op'>)</span> <span class='op'>!=</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>tostr</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>ValueError</span><span class='op'>,</span> <span class='str'>&quot;maketrans arguments must have same length&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>global</span> <span class='nam'>_idmapL</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>_idmapL</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>_idmapL</span> <span class='op'>=</span> <span class='nam'>list</span><span class='op'>(</span><span class='nam'>_idmap</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>L</span> <span class='op'>=</span> <span class='nam'>_idmapL</span><span class='op'>[</span><span class='op'>:</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>fromstr</span> <span class='op'>=</span> <span class='nam'>map</span><span class='op'>(</span><span class='nam'>ord</span><span class='op'>,</span> <span class='nam'>fromstr</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>i</span> <span class='key'>in</span> <span class='nam'>range</span><span class='op'>(</span><span class='nam'>len</span><span class='op'>(</span><span class='nam'>fromstr</span><span class='op'>)</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>L</span><span class='op'>[</span><span class='nam'>fromstr</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>]</span><span class='op'>]</span> <span class='op'>=</span> <span class='nam'>tostr</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&#39;&#39;</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>L</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>####################################################################</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>import</span> <span class='nam'>re</span> <span class='key'>as</span> <span class='nam'>_re</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>class</span> <span class='nam'>_multimap</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;Helper class for combining multiple mappings.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Used by .{safe_,}substitute() to combine the mapping and keyword</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; arguments.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>primary</span><span class='op'>,</span> <span class='nam'>secondary</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_primary</span> <span class='op'>=</span> <span class='nam'>primary</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_secondary</span> <span class='op'>=</span> <span class='nam'>secondary</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__getitem__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_primary</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_secondary</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>class</span> <span class='nam'>_TemplateMetaclass</span><span class='op'>(</span><span class='nam'>type</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>pattern</span> <span class='op'>=</span> <span class='str'>r&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; %(delim)s(?:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; (?P&lt;escaped&gt;%(delim)s) |&nbsp;&nbsp; # Escape sequence of two delimiters</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; (?P&lt;named&gt;%(id)s)&nbsp; &nbsp; &nbsp; |&nbsp;&nbsp; # delimiter and a Python identifier</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; {(?P&lt;braced&gt;%(id)s)}&nbsp;&nbsp; |&nbsp;&nbsp; # delimiter and a braced identifier</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &nbsp; (?P&lt;invalid&gt;)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # Other ill-formed delimiter exprs</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; )</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>cls</span><span class='op'>,</span> <span class='nam'>name</span><span class='op'>,</span> <span class='nam'>bases</span><span class='op'>,</span> <span class='nam'>dct</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>super</span><span class='op'>(</span><span class='nam'>_TemplateMetaclass</span><span class='op'>,</span> <span class='nam'>cls</span><span class='op'>)</span><span class='op'>.</span><span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>name</span><span class='op'>,</span> <span class='nam'>bases</span><span class='op'>,</span> <span class='nam'>dct</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='str'>&#39;pattern&#39;</span> <span class='key'>in</span> <span class='nam'>dct</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>pattern</span> <span class='op'>=</span> <span class='nam'>cls</span><span class='op'>.</span><span class='nam'>pattern</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>pattern</span> <span class='op'>=</span> <span class='nam'>_TemplateMetaclass</span><span class='op'>.</span><span class='nam'>pattern</span> <span class='op'>%</span> <span class='op'>{</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;delim&#39;</span> <span class='op'>:</span> <span class='nam'>_re</span><span class='op'>.</span><span class='nam'>escape</span><span class='op'>(</span><span class='nam'>cls</span><span class='op'>.</span><span class='nam'>delimiter</span><span class='op'>)</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='str'>&#39;id&#39;</span>&nbsp; &nbsp; <span class='op'>:</span> <span class='nam'>cls</span><span class='op'>.</span><span class='nam'>idpattern</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='op'>}</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>cls</span><span class='op'>.</span><span class='nam'>pattern</span> <span class='op'>=</span> <span class='nam'>_re</span><span class='op'>.</span><span class='nam'>compile</span><span class='op'>(</span><span class='nam'>pattern</span><span class='op'>,</span> <span class='nam'>_re</span><span class='op'>.</span><span class='nam'>IGNORECASE</span> <span class='op'>|</span> <span class='nam'>_re</span><span class='op'>.</span><span class='nam'>VERBOSE</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>class</span> <span class='nam'>Template</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;A string class for supporting $-substitutions.&quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>__metaclass__</span> <span class='op'>=</span> <span class='nam'>_TemplateMetaclass</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>delimiter</span> <span class='op'>=</span> <span class='str'>&#39;$&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>idpattern</span> <span class='op'>=</span> <span class='str'>r&#39;[_a-z][_a-z0-9]*&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>__init__</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>template</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>template</span> <span class='op'>=</span> <span class='nam'>template</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># Search for $$, $identifier, ${identifier}, and any bare $&#39;s</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>_invalid</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>mo</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>i</span> <span class='op'>=</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>start</span><span class='op'>(</span><span class='str'>&#39;invalid&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>lines</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>template</span><span class='op'>[</span><span class='op'>:</span><span class='nam'>i</span><span class='op'>]</span><span class='op'>.</span><span class='nam'>splitlines</span><span class='op'>(</span><span class='nam'>True</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>lines</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>colno</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>lineno</span> <span class='op'>=</span> <span class='num'>1</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>colno</span> <span class='op'>=</span> <span class='nam'>i</span> <span class='op'>-</span> <span class='nam'>len</span><span class='op'>(</span><span class='str'>&#39;&#39;</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>lines</span><span class='op'>[</span><span class='op'>:</span><span class='op'>-</span><span class='num'>1</span><span class='op'>]</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>lineno</span> <span class='op'>=</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>lines</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>ValueError</span><span class='op'>(</span><span class='str'>&#39;Invalid placeholder in string: line %d, col %d&#39;</span> <span class='op'>%</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='op'>(</span><span class='nam'>lineno</span><span class='op'>,</span> <span class='nam'>colno</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>substitute</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kws</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>)</span> <span class='op'>&gt;</span> <span class='num'>1</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>TypeError</span><span class='op'>(</span><span class='str'>&#39;Too many positional arguments&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>args</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>mapping</span> <span class='op'>=</span> <span class='nam'>kws</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>kws</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>mapping</span> <span class='op'>=</span> <span class='nam'>_multimap</span><span class='op'>(</span><span class='nam'>kws</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>mapping</span> <span class='op'>=</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Helper function for .sub()</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>convert</span><span class='op'>(</span><span class='nam'>mo</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Check the most common path first.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>named</span> <span class='op'>=</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;named&#39;</span><span class='op'>)</span> <span class='key'>or</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;braced&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>named</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>val</span> <span class='op'>=</span> <span class='nam'>mapping</span><span class='op'>[</span><span class='nam'>named</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># We use this idiom instead of str() because the latter will</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># fail if val is a Unicode containing non-ASCII characters.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&#39;%s&#39;</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>val</span><span class='op'>,</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;escaped&#39;</span><span class='op'>)</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>delimiter</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;invalid&#39;</span><span class='op'>)</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_invalid</span><span class='op'>(</span><span class='nam'>mo</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>ValueError</span><span class='op'>(</span><span class='str'>&#39;Unrecognized named group in pattern&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>pattern</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>pattern</span><span class='op'>.</span><span class='nam'>sub</span><span class='op'>(</span><span class='nam'>convert</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>template</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>safe_substitute</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kws</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>len</span><span class='op'>(</span><span class='nam'>args</span><span class='op'>)</span> <span class='op'>&gt;</span> <span class='num'>1</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>TypeError</span><span class='op'>(</span><span class='str'>&#39;Too many positional arguments&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>args</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>mapping</span> <span class='op'>=</span> <span class='nam'>kws</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>kws</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>mapping</span> <span class='op'>=</span> <span class='nam'>_multimap</span><span class='op'>(</span><span class='nam'>kws</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>mapping</span> <span class='op'>=</span> <span class='nam'>args</span><span class='op'>[</span><span class='num'>0</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Helper function for .sub()</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>convert</span><span class='op'>(</span><span class='nam'>mo</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>named</span> <span class='op'>=</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;named&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>named</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># We use this idiom instead of str() because the latter</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># will fail if val is a Unicode containing non-ASCII</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&#39;%s&#39;</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>mapping</span><span class='op'>[</span><span class='nam'>named</span><span class='op'>]</span><span class='op'>,</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>delimiter</span> <span class='op'>+</span> <span class='nam'>named</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>braced</span> <span class='op'>=</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;braced&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>braced</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&#39;%s&#39;</span> <span class='op'>%</span> <span class='op'>(</span><span class='nam'>mapping</span><span class='op'>[</span><span class='nam'>braced</span><span class='op'>]</span><span class='op'>,</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>except</span> <span class='nam'>KeyError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>delimiter</span> <span class='op'>+</span> <span class='str'>&#39;{&#39;</span> <span class='op'>+</span> <span class='nam'>braced</span> <span class='op'>+</span> <span class='str'>&#39;}&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;escaped&#39;</span><span class='op'>)</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>delimiter</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>mo</span><span class='op'>.</span><span class='nam'>group</span><span class='op'>(</span><span class='str'>&#39;invalid&#39;</span><span class='op'>)</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>delimiter</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>ValueError</span><span class='op'>(</span><span class='str'>&#39;Unrecognized named group in pattern&#39;</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>pattern</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>pattern</span><span class='op'>.</span><span class='nam'>sub</span><span class='op'>(</span><span class='nam'>convert</span><span class='op'>,</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>template</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>####################################################################</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># NOTE: Everything below here is deprecated.&nbsp; Use string methods instead.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># This stuff will go away in Python 3.0.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Backward compatible names for exceptions</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>index_error</span> <span class='op'>=</span> <span class='nam'>ValueError</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>atoi_error</span> <span class='op'>=</span> <span class='nam'>ValueError</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>atof_error</span> <span class='op'>=</span> <span class='nam'>ValueError</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>atol_error</span> <span class='op'>=</span> <span class='nam'>ValueError</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># convert UPPER CASE letters to lower case</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>lower</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;lower(s) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s converted to lowercase.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>lower</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Convert lower case letters to UPPER CASE</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>upper</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;upper(s) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s converted to uppercase.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>upper</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Swap lower case letters and UPPER CASE</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>swapcase</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;swapcase(s) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s with upper case characters</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; converted to lowercase and vice versa.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>swapcase</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Strip leading and trailing tabs and spaces</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>strip</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>chars</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;strip(s [,chars]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s with leading and trailing</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; whitespace removed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; If chars is given and not None, remove characters in chars instead.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; If chars is unicode, S will be converted to unicode before stripping.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>strip</span><span class='op'>(</span><span class='nam'>chars</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Strip leading tabs and spaces</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>lstrip</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>chars</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;lstrip(s [,chars]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s with leading whitespace removed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; If chars is given and not None, remove characters in chars instead.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>lstrip</span><span class='op'>(</span><span class='nam'>chars</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Strip trailing tabs and spaces</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>rstrip</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>chars</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;rstrip(s [,chars]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s with trailing whitespace removed.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; If chars is given and not None, remove characters in chars instead.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>rstrip</span><span class='op'>(</span><span class='nam'>chars</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Split a string into a list of space/tab-separated words</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>split</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>sep</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>maxsplit</span><span class='op'>=</span><span class='op'>-</span><span class='num'>1</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;split(s [,sep [,maxsplit]]) -&gt; list of strings</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a list of the words in the string s, using sep as the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; delimiter string.&nbsp; If maxsplit is given, splits at no more than</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; maxsplit places (resulting in at most maxsplit+1 words).&nbsp; If sep</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; is not specified or is None, any whitespace string is a separator.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; (split and splitfields are synonymous)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>split</span><span class='op'>(</span><span class='nam'>sep</span><span class='op'>,</span> <span class='nam'>maxsplit</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>splitfields</span> <span class='op'>=</span> <span class='nam'>split</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Split a string into a list of space/tab-separated words</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>rsplit</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>sep</span><span class='op'>=</span><span class='nam'>None</span><span class='op'>,</span> <span class='nam'>maxsplit</span><span class='op'>=</span><span class='op'>-</span><span class='num'>1</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;rsplit(s [,sep [,maxsplit]]) -&gt; list of strings</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a list of the words in the string s, using sep as the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; delimiter string, starting at the end of the string and working</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; to the front.&nbsp; If maxsplit is given, at most maxsplit splits are</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; done. If sep is not specified or is None, any whitespace string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; is a separator.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>rsplit</span><span class='op'>(</span><span class='nam'>sep</span><span class='op'>,</span> <span class='nam'>maxsplit</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Join fields with optional separator</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>join</span><span class='op'>(</span><span class='nam'>words</span><span class='op'>,</span> <span class='nam'>sep</span> <span class='op'>=</span> <span class='str'>&#39; &#39;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;join(list [,sep]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a string composed of the words in list, with</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; intervening occurrences of sep.&nbsp; The default separator is a</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; single space.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; (joinfields and join are synonymous)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>sep</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>words</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>joinfields</span> <span class='op'>=</span> <span class='nam'>join</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Find substring, raise exception if not found</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>index</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;index(s, sub [,start [,end]]) -&gt; int</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Like find but raises ValueError when the substring is not found.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>index</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Find last substring, raise exception if not found</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>rindex</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;rindex(s, sub [,start [,end]]) -&gt; int</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Like rfind but raises ValueError when the substring is not found.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>rindex</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Count non-overlapping occurrences of substring</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>count</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;count(s, sub[, start[,end]]) -&gt; int</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the number of occurrences of substring sub in string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; s[start:end].&nbsp; Optional arguments start and end are</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; interpreted as in slice notation.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>count</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Find substring, return -1 if not found</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>find</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;find(s, sub [,start [,end]]) -&gt; in</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the lowest index in s where substring sub is found,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; such that sub is contained within s[start,end].&nbsp; Optional</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; arguments start and end are interpreted as in slice notation.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return -1 on failure.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>find</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Find last substring, return -1 if not found</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>rfind</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;rfind(s, sub [,start [,end]]) -&gt; int</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the highest index in s where substring sub is found,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; such that sub is contained within s[start,end].&nbsp; Optional</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; arguments start and end are interpreted as in slice notation.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return -1 on failure.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm run hide_run'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>rfind</span><span class='op'>(</span><span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># for a bit of speed</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>_float</span> <span class='op'>=</span> <span class='nam'>float</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>_int</span> <span class='op'>=</span> <span class='nam'>int</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='nam'>_long</span> <span class='op'>=</span> <span class='nam'>long</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Convert string to float</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>atof</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;atof(s) -&gt; float</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the floating point number represented by the string s.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>_float</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Convert string to integer</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>atoi</span><span class='op'>(</span><span class='nam'>s</span> <span class='op'>,</span> <span class='nam'>base</span><span class='op'>=</span><span class='num'>10</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;atoi(s [,base]) -&gt; int</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the integer represented by the string s in the given</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; base, which defaults to 10.&nbsp; The string s must consist of one</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; or more digits, possibly preceded by a sign.&nbsp; If base is 0, it</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; is chosen from the leading characters of s, 0 for octal, 0x or</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; 0X for hexadecimal.&nbsp; If base is 16, a preceding 0x or 0X is</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; accepted.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>_int</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>base</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Convert string to long integer</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>atol</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>base</span><span class='op'>=</span><span class='num'>10</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;atol(s [,base]) -&gt; long</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return the long integer represented by the string s in the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; given base, which defaults to 10.&nbsp; The string s must consist</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; of one or more digits, possibly preceded by a sign.&nbsp; If base</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; is 0, it is chosen from the leading characters of s, 0 for</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; octal, 0x or 0X for hexadecimal.&nbsp; If base is 16, a preceding</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; 0x or 0X is accepted.&nbsp; A trailing L or l is not accepted,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; unless base is 0.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>_long</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>base</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Left-justify a string</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>ljust</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>width</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;ljust(s, width[, fillchar]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a left-justified version of s, in a field of the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; specified width, padded with spaces as needed.&nbsp; The string is</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; never truncated.&nbsp; If specified the fillchar is used instead of spaces.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>ljust</span><span class='op'>(</span><span class='nam'>width</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Right-justify a string</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>rjust</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>width</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;rjust(s, width[, fillchar]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a right-justified version of s, in a field of the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; specified width, padded with spaces as needed.&nbsp; The string is</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; never truncated.&nbsp; If specified the fillchar is used instead of spaces.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>rjust</span><span class='op'>(</span><span class='nam'>width</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Center a string</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>center</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>width</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;center(s, width[, fillchar]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a center version of s, in a field of the specified</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; width. padded with spaces as needed.&nbsp; The string is never</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; truncated.&nbsp; If specified the fillchar is used instead of spaces.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>center</span><span class='op'>(</span><span class='nam'>width</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Zero-fill a number, e.g., (12, 3) --&gt; &#39;012&#39; and (-3, 3) --&gt; &#39;-03&#39;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Decadent feature: the argument may be a string or a number</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># (Use of this is deprecated; it should be a string as with ljust c.s.)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>zfill</span><span class='op'>(</span><span class='nam'>x</span><span class='op'>,</span> <span class='nam'>width</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;zfill(x, width) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Pad a numeric string x with zeros on the left, to fill a field</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; of the specified width.&nbsp; The string x is never truncated.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='key'>not</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>x</span><span class='op'>,</span> <span class='nam'>basestring</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>x</span> <span class='op'>=</span> <span class='nam'>repr</span><span class='op'>(</span><span class='nam'>x</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>x</span><span class='op'>.</span><span class='nam'>zfill</span><span class='op'>(</span><span class='nam'>width</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Expand tabs in a string.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Doesn&#39;t take non-printing chars into account, but does understand \n.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>expandtabs</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>tabsize</span><span class='op'>=</span><span class='num'>8</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;expandtabs(s [,tabsize]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s with all tab characters replaced</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; by the appropriate number of spaces, depending on the current</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; column, and the tabsize (default 8).</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>expandtabs</span><span class='op'>(</span><span class='nam'>tabsize</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Character translation through look-up table.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>translate</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>table</span><span class='op'>,</span> <span class='nam'>deletions</span><span class='op'>=</span><span class='str'>&quot;&quot;</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;translate(s,table [,deletions]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s, where all characters occurring</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; in the optional argument deletions are removed, and the</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; remaining characters have been mapped through the given</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; translation table, which must be a string of length 256.&nbsp; The</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; deletions argument is not allowed for Unicode strings.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>deletions</span> <span class='key'>or</span> <span class='nam'>table</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>translate</span><span class='op'>(</span><span class='nam'>table</span><span class='op'>,</span> <span class='nam'>deletions</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Add s[:0] so that if s is Unicode and table is an 8-bit string,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># table is converted to Unicode.&nbsp; This means that table *cannot*</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># be a dictionary -- for that feature, use u.translate() directly.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>translate</span><span class='op'>(</span><span class='nam'>table</span> <span class='op'>+</span> <span class='nam'>s</span><span class='op'>[</span><span class='op'>:</span><span class='num'>0</span><span class='op'>]</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Capitalize a string, e.g. &quot;aBc&nbsp; dEf&quot; -&gt; &quot;Abc&nbsp; def&quot;.</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>capitalize</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;capitalize(s) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of the string s with only its first character</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; capitalized.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>capitalize</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Substring replacement (global)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>def</span> <span class='nam'>replace</span><span class='op'>(</span><span class='nam'>s</span><span class='op'>,</span> <span class='nam'>old</span><span class='op'>,</span> <span class='nam'>new</span><span class='op'>,</span> <span class='nam'>maxsplit</span><span class='op'>=</span><span class='op'>-</span><span class='num'>1</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='str'>&quot;&quot;&quot;replace (str, old, new[, maxsplit]) -&gt; string</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; Return a copy of string str with all occurrences of substring</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; old replaced by new. If the optional argument maxsplit is</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; given, only the first maxsplit occurrences are replaced.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='str'>&nbsp; &nbsp; &quot;&quot;&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>s</span><span class='op'>.</span><span class='nam'>replace</span><span class='op'>(</span><span class='nam'>old</span><span class='op'>,</span> <span class='nam'>new</span><span class='op'>,</span> <span class='nam'>maxsplit</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># Try importing optional built-in module &quot;strop&quot; -- if it exists,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># it redefines some string operations that are 100-1000 times faster.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># It also defines values for whitespace, lowercase and uppercase</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># that match &lt;ctype.h&gt;&#39;s definitions.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>try</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>from</span> <span class='nam'>strop</span> <span class='key'>import</span> <span class='nam'>maketrans</span><span class='op'>,</span> <span class='nam'>lowercase</span><span class='op'>,</span> <span class='nam'>uppercase</span><span class='op'>,</span> <span class='nam'>whitespace</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='nam'>letters</span> <span class='op'>=</span> <span class='nam'>lowercase</span> <span class='op'>+</span> <span class='nam'>uppercase</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>except</span> <span class='nam'>ImportError</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>pass</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># Use the original versions</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'>########################################################################</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># the Formatter class</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># see PEP 3101 for details and purpose of this class</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># The hard parts are reused from the C implementation.&nbsp; They&#39;re exposed as &quot;_&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># prefixed methods of str and unicode.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># The overall parser is implemented in str._formatter_parser.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='com'># The field name parser is implemented in str._formatter_field_name_split</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'><span class='key'>class</span> <span class='nam'>Formatter</span><span class='op'>(</span><span class='nam'>object</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>format</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>format_string</span><span class='op'>,</span> <span class='op'>*</span><span class='nam'>args</span><span class='op'>,</span> <span class='op'>**</span><span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>vformat</span><span class='op'>(</span><span class='nam'>format_string</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>vformat</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>format_string</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>used_args</span> <span class='op'>=</span> <span class='nam'>set</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>result</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_vformat</span><span class='op'>(</span><span class='nam'>format_string</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>,</span> <span class='nam'>used_args</span><span class='op'>,</span> <span class='num'>2</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>check_unused_args</span><span class='op'>(</span><span class='nam'>used_args</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>result</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>_vformat</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>format_string</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>,</span> <span class='nam'>used_args</span><span class='op'>,</span> <span class='nam'>recursion_depth</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>recursion_depth</span> <span class='op'>&lt;</span> <span class='num'>0</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>ValueError</span><span class='op'>(</span><span class='str'>&#39;Max string recursion exceeded&#39;</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>result</span> <span class='op'>=</span> <span class='op'>[</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>literal_text</span><span class='op'>,</span> <span class='nam'>field_name</span><span class='op'>,</span> <span class='nam'>format_spec</span><span class='op'>,</span> <span class='nam'>conversion</span> <span class='key'>in</span> <span class='xx'>\</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>self</span><span class='op'>.</span><span class='nam'>parse</span><span class='op'>(</span><span class='nam'>format_string</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># output the literal text</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>literal_text</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>result</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>literal_text</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># if there&#39;s a field, output it</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>field_name</span> <span class='key'>is</span> <span class='key'>not</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># this is some markup, find the object and do</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#&nbsp; the formatting</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># given the field_name, find the object it references</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#&nbsp; and the argument it came from</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span><span class='op'>,</span> <span class='nam'>arg_used</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>get_field</span><span class='op'>(</span><span class='nam'>field_name</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>used_args</span><span class='op'>.</span><span class='nam'>add</span><span class='op'>(</span><span class='nam'>arg_used</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># do any conversion on the resulting object</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>convert_field</span><span class='op'>(</span><span class='nam'>obj</span><span class='op'>,</span> <span class='nam'>conversion</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># expand the format spec, if needed</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>format_spec</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>_vformat</span><span class='op'>(</span><span class='nam'>format_spec</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>,</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>used_args</span><span class='op'>,</span> <span class='nam'>recursion_depth</span><span class='op'>-</span><span class='num'>1</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># format the object and append to the result</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>result</span><span class='op'>.</span><span class='nam'>append</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>.</span><span class='nam'>format_field</span><span class='op'>(</span><span class='nam'>obj</span><span class='op'>,</span> <span class='nam'>format_spec</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='str'>&#39;&#39;</span><span class='op'>.</span><span class='nam'>join</span><span class='op'>(</span><span class='nam'>result</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>get_value</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>key</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>isinstance</span><span class='op'>(</span><span class='nam'>key</span><span class='op'>,</span> <span class='op'>(</span><span class='nam'>int</span><span class='op'>,</span> <span class='nam'>long</span><span class='op'>)</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>args</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>kwargs</span><span class='op'>[</span><span class='nam'>key</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>check_unused_args</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>used_args</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>pass</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>format_field</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>value</span><span class='op'>,</span> <span class='nam'>format_spec</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>format</span><span class='op'>(</span><span class='nam'>value</span><span class='op'>,</span> <span class='nam'>format_spec</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>convert_field</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>value</span><span class='op'>,</span> <span class='nam'>conversion</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># do any conversion on the resulting object</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>conversion</span> <span class='op'>==</span> <span class='str'>&#39;r&#39;</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>repr</span><span class='op'>(</span><span class='nam'>value</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>conversion</span> <span class='op'>==</span> <span class='str'>&#39;s&#39;</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>str</span><span class='op'>(</span><span class='nam'>value</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>elif</span> <span class='nam'>conversion</span> <span class='key'>is</span> <span class='nam'>None</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>value</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>raise</span> <span class='nam'>ValueError</span><span class='op'>(</span><span class='str'>&quot;Unknown converion specifier {0!s}&quot;</span><span class='op'>.</span><span class='nam'>format</span><span class='op'>(</span><span class='nam'>conversion</span><span class='op'>)</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># returns an iterable that contains tuples of the form:</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># (literal_text, field_name, format_spec, conversion)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># literal_text can be zero length</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># field_name can be None, in which case there&#39;s no</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'>#&nbsp; object to format and output</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># if field_name is not None, it is looked up, formatted</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'>#&nbsp; with format_spec and conversion and then used</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>parse</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>format_string</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>format_string</span><span class='op'>.</span><span class='nam'>_formatter_parser</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'># given a field_name, find the object it references.</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'>#&nbsp; field_name:&nbsp;&nbsp; the field being looked up, e.g. &quot;0.name&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'>#&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; or &quot;lookup[3]&quot;</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'>#&nbsp; used_args:&nbsp; &nbsp; a set of which args have been used</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; <span class='com'>#&nbsp; args, kwargs: as passed in to vformat</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; <span class='key'>def</span> <span class='nam'>get_field</span><span class='op'>(</span><span class='nam'>self</span><span class='op'>,</span> <span class='nam'>field_name</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>first</span><span class='op'>,</span> <span class='nam'>rest</span> <span class='op'>=</span> <span class='nam'>field_name</span><span class='op'>.</span><span class='nam'>_formatter_field_name_split</span><span class='op'>(</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span> <span class='op'>=</span> <span class='nam'>self</span><span class='op'>.</span><span class='nam'>get_value</span><span class='op'>(</span><span class='nam'>first</span><span class='op'>,</span> <span class='nam'>args</span><span class='op'>,</span> <span class='nam'>kwargs</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'># loop through the rest of the field_name, doing</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='com'>#&nbsp; getattr or getitem as needed</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>for</span> <span class='nam'>is_attr</span><span class='op'>,</span> <span class='nam'>i</span> <span class='key'>in</span> <span class='nam'>rest</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>if</span> <span class='nam'>is_attr</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span> <span class='op'>=</span> <span class='nam'>getattr</span><span class='op'>(</span><span class='nam'>obj</span><span class='op'>,</span> <span class='nam'>i</span><span class='op'>)</span><span class='strut'>&nbsp;</span></p>
<p class='pln'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>else</span><span class='op'>:</span><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class='nam'>obj</span> <span class='op'>=</span> <span class='nam'>obj</span><span class='op'>[</span><span class='nam'>i</span><span class='op'>]</span><span class='strut'>&nbsp;</span></p>
<p class='pln'><span class='strut'>&nbsp;</span></p>
<p class='stm mis'>&nbsp; &nbsp; &nbsp; &nbsp; <span class='key'>return</span> <span class='nam'>obj</span><span class='op'>,</span> <span class='nam'>first</span><span class='strut'>&nbsp;</span></p>
    
</td>
</tr>
</table>
</div>

</body>
</html>
